package class11;


import common.ArrayUtils;

public class TesDemo {
    public static void main(String[] args) {
        int start = 2, target = 4, N = 5, times = 4;
        int res = way1(start, target, N, times);
        System.out.println("res = " + res);
    }

    public static int way1(int start, int target, int N, int times) {
        int[][] dp = new int[N + 1][times + 1];
        dp[target][0] = 1;
        for (int i = 1; i <= times; i++) {
            dp[1][i] = dp[2][i - 1];
            for (int j = 2; j < N; j++) {
                dp[j][i] = dp[j - 1][i - 1] + dp[j + 1][i - 1];
            }
            dp[N][i] = dp[N - 1][i - 1];

        }
        return dp[start][times];
    }

}
